import request from '@/utils/request'

// 获取题目列表
export function getQuestions(params) {
    return request({
        url: '/questions',
        method: 'get',
        params
    })
}

// 获取题目详情
export function getQuestion(id) {
    return request({
        url: `/questions/${id}`,
        method: 'get'
    })
}

// 新增题目
export function addQuestion(data) {
    return request({
        url: '/questions',
        method: 'post',
        data
    })
}

// 修改题目
export function updateQuestion(data) {
    return request({
        url: `/questions/${data.id}`,
        method: 'put',
        data
    })
}

// 删除题目
export function deleteQuestion(id) {
    return request({
        url: `/questions/${id}`,
        method: 'delete'
    })
}

// 导入题目
export function importQuestions(file) {
    const formData = new FormData()
    formData.append('file', file)
    return request({
        url: '/questions/import',
        method: 'post',
        data: formData,
        headers: {
            'Content-Type': 'multipart/form-data'
        }
    })
}

// 导出题目
export function exportQuestions(ids) {
    return request({
        url: '/questions/export',
        method: 'post',
        data: ids,
        responseType: 'blob',
        headers: {
            'Content-Type': 'application/json'
        }
    })
}

// 去重题目
export function removeDuplicates() {
    return request({
        url: '/questions/remove-duplicates',
        method: 'post'
    })
} 